<template>
    <div class="pt44">
        <dl class="plr15">
            <dd>
                <div class="d_title">产品名称</div>
                <div class="d_content">{{ goodsName }}</div>
            </dd>
            <dd>
                <div class="d_title">订单号</div>
                <div class="d_content">{{ orderId }}</div>
            </dd>
            <dd>
                <div class="d_title">借款日期</div>
                <div class="d_content">{{ londDate }}</div>
            </dd>
            <dd>
                <div class="d_title">申请人姓名</div>
                <div class="d_content">{{ applyName }}</div>
            </dd>
            <dd>
                <div class="d_title">{{ loanMsg }}</div>
                <div class="d_content">{{ loanMoney }}元</div>
            </dd>
            <dd v-show="orderState == '02'">
                <div class="d_title">冻结金额</div>
                <div class="d_content">{{ freezeAmt }}元</div>
            </dd>
            <dd>
                <div class="d_title">信用卡号</div>
                <div class="d_content">{{ cardId }}</div>
            </dd>
            <dd>
                <div class="d_title">交易状态</div>
                <div class="d_content">{{ state }}</div>
            </dd>
            <dd v-show="orderState == '02'  && repayState == '01'">
                <div class="d_title">借款时长</div>
                <div class="d_content">{{ londDays }}天</div>
            </dd>
            <dd v-show="jklx!='' && repayState == '01'">
                <div class="d_title">借款利息</div>
                <div class="d_content">{{ jklx }} 元</div>
            </dd>
            <dd v-show="repayState == '01'">
                <div class="d_title">还款方式</div>
                <div class="d_content">{{ repayType }}</div>
            </dd>
            <dd v-show="repayCardId!=''">
                <div class="d_title">还款卡号</div>
                <div class="d_content">{{ repayCardId }}</div>
            </dd>
            <dd v-show="remark!=''">
                <div class="d_title">备注</div>
                <div class="d_content">{{ remark }}</div>
            </dd>
        </dl>
    </div>
</template>

<script>
var cm = require("../components/common.js");
export default  {
    name: 'orderDetails',  // 组件贷款订单详情
    data () {  // 数据
        return {
            msg: 'orderDetails',
            applyName:"",
            loanMoney:"",
            cardId:"",
            londDate:"",
            state:"",
            londDays:"",
            londInterest:"",
            repayType:"主动还款",
            repayCardId:"",
            remark:"",
            jklx:"",      //借款总利息
            orderState:"",
            freezeAmt:"",
            goodsName:"",
            orderId:"",
            repayState:"",
            loanMsg:"借款本金"

        }
    },
    methods:{ // 自定义方法，可对data进行处理
        initVar(){
            this.applyName = "";
            this.loanMoney = "";
            this.cardId = "";
            this.londDate = "";
            this.state = "";
            this.londDays = "";
            this.londInterest = "";
            this.repayType = "主动还款";
            this.repayCardId = "";
            this.remark = "";
            this.jklx = "";
            this.orderState = "";
            this.freezeAmt = "";
            this.goodsName = "";
            this.orderId = "";
            this.repayState ="";
        },
        dealData(arecrd){
            var statemsgMap = {
                "00":"已还款",
                "01":"未还款",
                "02":"失败"
            };
            this.applyName = arecrd.custName;
            this.loanMoney = cm.comdify(parseFloat(arecrd.borrowAmt).toFixed(2));
            this.freezeAmt =  cm.comdify(parseFloat(arecrd.freezeAmt).toFixed(2));
            this.cardId = arecrd.creditCardNo;
            this.londDate = cm.getDateStrFormate1(arecrd.serialNoTime,"second");
            this.orderId = arecrd.orderId.replace("~","");
            this.goodsName = "小通帮你借";
            if(arecrd.channelNo == "02"){
                this.goodsName = "小通帮你延";
                this.loanMsg = "交易本金";
            }
            if(arecrd.repayType =="02" && arecrd.channelNo=="01"){
                this.repayType = "被动还款";
            }
            if(arecrd.repayCard){
                this.repayCardId = arecrd.repayCard;
            }
            this.orderState = arecrd.orderState;
            if(arecrd.orderState == "01"){
                this.state = "待完成交易";
                if(arecrd.channelNo=="02"){
                    this.state = "待完成交易";
                }
            }else if(arecrd.orderState == "02"){
                this.state = "借款成功待还款";
                if(arecrd.channelNo=="02"){
                    this.state = "延期成功待还款";
                }
                if(arecrd.repayState == "01"){
                    this.state = "已还款";
                }
            }else{
                this.state = "失败";
                this.remark = arecrd.nt.split(":")[1];
            }
            this.repayState = arecrd.repayState;
            this.londDays = "";
            if(arecrd.prepayCostCycle || arecrd.prepayCostCycle == 0){

                this.londDays = arecrd.prepayCostCycle;
            }/*else{
                var theNow = new Date(this.$store.state.nowDate);
                theNow.setHours(23);
                var applyDate = new Date(this.londDate.replace(/"-"/g,"/"));
                this.londDays = Math.ceil(cm.DateDiff(applyDate,theNow));
            }*/
            this.londInterest = cm.comdify(parseFloat(arecrd.borrowAmt).toFixed(2));
            this.jklx = "";
            if(arecrd.repayState == "01"){
                this.jklx = (parseFloat(arecrd.dayRate) * this.londDays  * arecrd.borrowAmt/100).toFixed(2);
            }

            if(arecrd.channelNo=="02"/* && arecrd.repayType =="01"*/){
                this.jklx = (parseFloat(arecrd.dayRate) * this.londDays  * arecrd.borrowAmt/100 + arecrd.borrowAmt * arecrd.serviceRate/100).toFixed(2);
            }

        },
    },
    beforeMount:function  () {
        var lrParaments = {
            orderId:this.$store.state.detailItem.orderId,
            serialNo:this.$store.state.detailItem.detailSerialNo,
            servlet_type:"query_orderByOrderId"
        }
        var _this = this;
        $.post(XtsdOrderServlet, lrParaments, function(lrdata) {
            console.dir(lrdata);
            if(lrdata.xtsd_OrderInfo_response && lrdata.xtsd_OrderInfo_response.respCode== "0000" && lrdata.xtsd_OrderInfo_response.resXtsdOrderInfos_arrays && lrdata.xtsd_OrderInfo_response.resXtsdOrderInfos_arrays.resXtsdOrderInfos){
                _this.dealData(lrdata.xtsd_OrderInfo_response.resXtsdOrderInfos_arrays.resXtsdOrderInfos[0]);


            }
        });
    },

}
</script>

<style lang='scss' scoped>
dl{
    background-color: #fff;
    padding-top: 10px 0;
    line-height: 36px;
}
.d_title{
    display: inline-block;
    float: left;
    width: 100px;
}
</style>
